﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;
using UFIDA.U9.SM.Ship;
using UFIDA.U9.PM.PO;
using UFSoft.UBF.PL;
using UFIDA.U9.PM.Rcv;
using UFIDA.U9.SM.RMA;
using UFIDA.U9.SM.SO;
using UFIDA.U9.CBO.SCM.Customer;
using UFIDA.U9.PR.PurchaseRequest;
using UFIDA.U9.AP.Payment;
using UFIDA.U9.CBO.FI.Enums;
using UFIDA.U9.PPR.PurPriceAdjustment;


namespace UFIDA.U9.Cust.LS.PlugBE
{
    /// <summary>
    /// 双虎家私
    /// 厂商调价单
    /// 提交时,清空私有扩展字段1/2/3
    /// </summary>
    class SHPPRExtend : IEventSubscriber
    {
        //配置XX.sub.xml文件放置到portal/bin下，dll文件放置到portal/ApplicationServer/Libs下
        public void Notify(params object[] args)
        {
            if (args != null && args.Length != 0 && args[0] is EntityEvent)
            {
                BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
                PurPriceAdjustment be = key.GetEntity() as PurPriceAdjustment;
                if (be == null)
                    return;
                if((be.Status == UFIDA.U9.PPR.Enums.Status.Approving 
                    && be.OriginalData.Status == UFIDA.U9.PPR.Enums.Status.Opened))
                {
                    //清空私有字段
                    using(ISession session = Session.Open())
                    {
                        be.DescFlexField.PrivateDescSeg1 = "";
                        be.DescFlexField.PrivateDescSeg2 = "";
                        be.DescFlexField.PrivateDescSeg3 = "";

                        session.Commit();
                    }
                }
            }
        }
    }
}
